#define   _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <stdlib.h>
typedef struct BinaryTree
{
    struct BinaryTree* left;
    struct BinaryTree* right;
    int val;
}BTNode;
BTNode* CreateBinaryTree(char* a, int* i)
{
    BTNode* root = (BTNode*)malloc(sizeof(BTNode));
    if (a[*i] == '#')
    {
        (*i)++;
        return NULL;
    }
    root->val = a[(*i)++];
    root->left = CreateBinaryTree(a, i);
    root->right = CreateBinaryTree(a, i);
    return root;
}
void BinaryTreePrevOrder(BTNode* root)
{
    if (root == NULL)
        return;

    BinaryTreePrevOrder(root->left);
    printf("%c ", root->val);
    BinaryTreePrevOrder(root->right);
}

int main() {
    char a[100];
    scanf("%s", a);
    int i = 0;
    BTNode* ret = CreateBinaryTree(a, &i);
    BinaryTreePrevOrder(ret);
    return 0;
}